import request from "@/utils/request";

//获取所有帖子
export function getAllNotesAPI() {
    return request({
        url:'/tNotes/selectAll',
        method:'get',
    })
}

//查询指定uid下的所有帖子
export function getNotesByUidAPI(uid) {
    return request({
        url:'/tNotes/selectNotesByUid',
        method:'get',
        params:{
            uid:uid
        }
    })
}

//关键词搜索
export function searchNoteByKeyWordAPI(keyword) {
    return request({
        url:`/tNotes/${keyword}`,
        method:'get',
    })
}

//发布帖子
export const postNoteAPI = (formData) => {
    return request({
        url: '/tNotes/add',
        method: 'POST',
        data: formData
    })
}

//更新帖子
export function updateNoteAPI(note) {
    return request({
        url:'/tNotes/update',
        method:'put',
        data:note
    })
}

//分页获取帖子
export function getNotesByPageAPI(pageSize,pageNum) {
    return request({
        url:'/tNotes/selectPage',
        method:'get',
        params:{
            pageSize:pageSize,
            pageNum:pageNum
        }
    })
}

//修改帖子
export function changeNoteAPI(note) {
    return request({
        url:'/tNotes/update',
        method:'put',
        data:note
    })
}

//删除指定帖子
export function deleteNoteByNidAPI(nid) {
    return request({
        url:`/tNotes/delete/${nid}`,
        method:'delete',
    })
}


//获取指定帖子的详情
export function getNoteDetailAPI(nid) {
    return request({
        url:`/tNotes/selectById/${nid}`,
        method:'get',
    })
}

//获取指定帖子下的所有评论
export function getCommentsByNidAPI(nid) {
    return request({
        url:`/discuss/getByPostId/comment/${nid}`,
        method:'get',
    })
}

//分页获取所有评论
export function getCommentsByPageAPI(pageSize,pageNum) {
    return request({
        url:'/discuss/selectPage',
        method:'get',
        params:{
            pageSize:pageSize,
            pageNum:pageNum
        }
    })
}

//发布评论
export function sendCommentAPI(comment) {
    return request({
        url:`/discuss/addComment`,
        method:'post',
        data:comment,
    })
}

//删除指定评论
export function deleteCommentAPI(id) {
    return request({
        url:`/discuss/delete/${id}`,
        method:'delete',
    })
}


export function submitClueAPI(id) {
    return request({
        url:``,
        method:'post',
    })
}